﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>jb-aptech毕业设计项目</TITLE>
    <meta name="renderer" content="ie-comp">
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="script/common.js"></script>
    <script src="script/validate.js"></script>
    <link rel="stylesheet" type="text/css" href="ExtJS/resources/css/ext-all.css">
    <script type="text/javascript" src="ExtJS/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="ExtJS/ext-all.js"></script>
    <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css"></link>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/vue.js"></script>
</head>
<script type="text/javascript">
    function mySearch(){
        var arrName=new Array();
        arrName[0]="usrName";
        checkWay(arrName);
        document.sysUserForm.submit();
    }
</script>
<body>
<div class="page_title">权限管理 > 用户管理 > 系统用户管理</div>
<form id="app" name="sysUserForm" method="post" action="/CRM/sysUser.do">
    <input type="hidden" name="method" value="userForward">
    <div class="button_bar">
        <button class="common_button" onclick="help('');">帮助</button>
        <button class="common_button" @click="createUser()" type="button">新建</button>
        <button @click="query(1)" class="common_button" type="button"  >查询</button>
    </div>
    <table class="query_form_table">
        <tr>
            <th>
                用户名
            </th>
            <td>
                     <input  v-model="usr_user.usr_name"  type="text" name="usrName" size="20"    >
            </td>
            <th>
                是否禁用
            </th>
            <td>
                <select v-model="usr_user.usr_flag" >
                    <option value="-1">全部</option>
                    <option value="1">正常</option>
                    <option value="0">禁用</option>
                </select>
            </td>
        </tr>
    </table>
    <br/>
    <table class="data_list_table">
        <tr>
            <th>编号</th>
            <th>用户名</th>
            <th>角色</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        <tr v-for="u in users">
            <td class="list_data_text">{{u.usr_id}}</td>
            <td class="list_data_text">{{u.usr_name}}</td>
            <td class="list_data_text">{{u.role_name}}</td>
            <td class="list_data_text">
                {{u.usr_flag==1?'正常':'禁用'}}
            </td>
            <td class="list_data_op">
                <img   title="编辑" src="/html/images/bt_edit.gif" class="op_button" @click="edit(u)"/>
                <img  title="指派" @click="designate(u)"  src="/html/images/bt_linkman.gif" class="op_button" />
                <img  title="查看" src="/html/images/bt_deal.gif" class="op_button" @click="find(u)"/>
                <img   title="删除" src="/html/images/bt_del.gif" class="op_button" @click="del(u.usr_id)"/>
            </td>
        </tr>
        <tr>
        <tr>
            <th colspan="100" class="pager">
                <div class="pager">
                    共{{pageInfo.total}}条记录
                    每页<input style="width: 30px;text-align: center" v-model="pageInfo.pageSize" />条
                    第<input v-model="pageInfo.pageNum" style="width: 30px;text-align: center"/>页/共{{pageInfo.pages}}页
                    <a @click="query(1)" href="javascript:;">第一页</a>
                    <a @click="query(pageInfo.pageNum-1)" href="javascript:;">上一页</a>
                    <a @click="query(pageInfo.pageNum+1)" href="javascript:;">下一页</a>
                    <a @click="query(pageInfo.pages)" href="javascript:;">最后一页</a>
                    转到<input v-model="pageInfo.pageNum" style="width: 30px;text-align: center"  />页
                    <button  @click="query(pageInfo.pageNum)"  type="button">GO</button>
                </div>
            </th>
        </tr>
    </table>
</form>
<script >
    var app=new Vue({
        el:"#app",
        data:{
            users:[],
            pageInfo:'',
            usr_user:{
                usr_name:'',
                usr_flag:'-1',
                pageNum:'',
                role_name:'',
                usrId:''
            },
            usrId:''
        },
        methods:{
            query(num){
                this.pageInfo.pageNum=num;
                if(num<1){
                    this.pageInfo.pageNum=1;
                }
                if(num>this.pageInfo.pages)
                    this.pageInfo.pageNum=this.pageInfo.pages;

                this.usr_user.pageNum=this.pageInfo.pageNum;
                $.getJSON("/SysUser/queryPage",this.usr_user,function(json){
                    app.users=json.data.pageInfo.list;
                    app.pageInfo=json.data.pageInfo;
                });
            },
            edit(u){
                    sessionStorage.setItem("u",JSON.stringify(u));
                    location="/html/~right/user/edit.html";
            },
            designate(ui){
                sessionStorage.setItem("designate",JSON.stringify(ui));
                location="/html/~right/user/dispatch.html";
            },
            find(us){
                sessionStorage.setItem("us",JSON.stringify(us));
                location="/html/~right/user/detail.html";
            },
            del(usrId){
                this.usrId=JSON.parse(sessionStorage.getItem("sysUsers")).usr_id;
                alert(this.usrId);
                if(usrId==this.usrId){
                    alert("当前用户不能删除！");
                }else{
                    $.getJSON("/deleteUserById/"+usrId,function(json){
                        if(json.code==200){
                            alert("删除成功！");
                        }else{
                            alert("删除失败！");
                        }
                        location="/html/~right/user/list.html";
                    });
                }
            },
            createUser(){
                location="/html/~right/user/add.html";
            }
        },
        created(){
            $.getJSON("/SysUser/queryPage",{},function(json){
                app.users=json.data.pageInfo.list;
                app.pageInfo=json.data.pageInfo;
            });

        }
    });
</script>
</body>
</html>





